import numpy as np
import matplotlib.pyplot as plt
from math import ceil, floor, sqrt

linewidth = 1
markersize = 4
plt.figure(1)

througput_sum = 0
througput = []
with open( "Detour_DCTCP_16ToRs_8Hosts_8Links_0.6Load_0.2Time.txt", 'r') as f:
    for line in f.readlines():
    	split = line.split()
        througput.append(float(split[3])*1000)   
througput.sort()

for x in througput:
	througput_sum += x

cdfx = througput
cdfy = np.linspace(1 / len(througput), 1.0, len(througput))
print 'througput_sum', througput_sum
plt.semilogx(cdfx, cdfy,'r', linewidth=1, markersize=4, label='OSA')

througput2 = []
with open( "OvS_DCTCP_16ToRs_8Hosts_8Links_0.6Load_0.2Time.txt", 'r') as f:
    for line in f.readlines():
    	split = line.split()
        througput2.append(float(split[3])*1000)   
througput2.sort()
througput_sum2 = 0
for x in througput2:
	througput_sum2 += x

cdfx2 = througput2
cdfy2 = np.linspace(1 / len(througput2), 1.0, len(througput2))
print 'througput_sum2', througput_sum2
plt.semilogx(cdfx2, cdfy2,'b', linewidth=1, markersize=4, label='OSA')


througput3 = []
with open( "Jelly_DCTCP_16ToRs_8Hosts_8Links_0.6Load_0.2Time.txt", 'r') as f:
    for line in f.readlines():
    	split = line.split()
        througput3.append(float(split[3])*1000)   
througput3.sort()
througput_sum3 = 0
for x in througput3:
	througput_sum3 += x

cdfx3 = througput3
cdfy3 = np.linspace(1 / len(througput3), 1.0, len(througput3))
print 'througput_sum3', througput_sum3
plt.semilogx(cdfx3, cdfy3,'y', linewidth=1, markersize=4, label='OSA')

plt.grid()
plt.show()

